package com.lyfei.ydc.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lyfei.ydc.domain.entity.Category;
import com.lyfei.ydc.mapper.CategoryMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("categoryService")
public class CategoryService extends BaseService<CategoryMapper, Category> {

    public List<Category> getRootCategories() {
        return this.list(new LambdaQueryWrapper<Category>().eq(Category::getIsRoot, true).orderByAsc(Category::getIndex));
    }

    public List<Category> getAllSubCategories() {
        return this.list(new LambdaQueryWrapper<Category>().eq(Category::getIsRoot, false).orderByAsc(Category::getIndex));
    }
}
